import { Chessman } from "./Chessman";

export default class ChessSoldier extends Chessman {
  constructor(chessName, camp, x, y, key, chessId) {
    super(chessName, camp, x, y, key, chessId);
  }
  predictionMove(chessList, path?) {
    const res = [];
    const temp = [];
    let evolution = false;
    if (this.camp === "red") {
      evolution = this.y < 5;
      if (this.y - 1 >= 0) temp.push([this.x, this.y - 1]);
    } else {
      evolution = this.y > 4;
      if (this.y + 1 <= 9) temp.push([this.x, this.y + 1]);
    }
    if (evolution) {
      temp.push([this.x + 1, this.y]);
      temp.push([this.x - 1, this.y]);
    }
    res.push(...this.filterChessman(temp, [...chessList]));
    return { data: this, path: res };
  }
}
